home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 201-225 / disk_222 / plplot / src / source.zoo / plxytx.c < prev    next >
C/C++ Source or Header  |  1989-05-15  |  984b  |  38 lines

  1. /* Prints out text along a sloping axis joining world coordinates */
  2. /* (wx1,wy1) to (wx2,wy2). Parameters are as for plmtext          */
  3.  
  4. #include "plplot.h"
  5. #include <math.h>
  6.  
  7. void plxytx(wx1,wy1,wx2,wy2,disp,pos,just,text)
  8. float wx1,wy1,wx2,wy2,disp,pos,just;
  9. char *text;
  10. {      
  11.       int refx, refy;
  12.       float shift, cc, ss, def, ht;
  13.       float xform[4], diag;
  14.       float xscl, xoff, yscl, yoff, wx, wy;
  15.    
  16.       gchr(&def,&ht);
  17.       gwm(&xscl,&xoff,&yscl,&yoff);
  18.       cc = xscl * (wx2-wx1);
  19.       ss = yscl * (wy2-wy1);
  20.       diag = sqrt(cc*cc + ss*ss);
  21.       cc = cc/diag;
  22.       ss = ss/diag;
  23.  
  24.       xform[0] = cc;
  25.       xform[1] = 0.0;
  26.       xform[2] = ss;
  27.       xform[3] = 1.0;
  28.  
  29.       shift = 0.0;
  30.       if (just != 0.0) shift = plstrl(text) * just;
  31.       wx = wx1 + pos * (wx2 - wx1);
  32.       wy = wy1 + pos * (wy2 - wy1);
  33.       
  34.       refx = mmpcx(wcmmx(wx) - shift * cc);
  35.       refy = mmpcy(wcmmy(wy) - shift * ss - disp * ht);
  36.       plstr(0,xform,refx,refy,text);
  37. }
  38.